import pandas as pd
from sklearn.preprocessing import LabelEncoder
import math
# 加载数据
df = pd.read_csv('shandong.csv')

# 查看原始数据集中 method 列的唯一值
unique_methods = df['Education'].unique()
print("Original unique method values:", unique_methods)

# 使用 LabelEncoder 对 method 列进行编码
method_encoder = LabelEncoder()
df['method_encoded'] = method_encoder.fit_transform(df['Education'])

# 创建编码映射关系
method_mapping = dict(zip(method_encoder.transform(unique_methods), unique_methods))

# 打印编码映射关系
print("Encoded method values and their corresponding original values:")
for encoded_value, original_value in method_mapping.items():
    print(f"{encoded_value}: {original_value}")

# 找到 5.98 对应的字符串值
encoded_value =math.ceil(1.98)
if encoded_value in method_mapping:
    original_value = method_mapping[encoded_value]
    print(f"The original value corresponding to method=5.98 is: {original_value}")
else:
    print(f"No original value corresponds to method={encoded_value}")
